﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using StaticPlugin;
using System.Windows.Forms;
using MosWar;

namespace MosWarAdv
{
    class jOK : AJob
    {

        private string status = "";
        private bool available = true;
        private int priority = 50;
        private jOKsetup setup = new jOKsetup();
        private string strOKurl = "www.moswar.ru/huntclub/";

        protected override string getName()
        {
            return "Охотничий клуб";
        }

        protected override string getStatus()
        {
            return status;
        }

        protected override bool getAvailable()
        {
            return available;
        }

        protected override int getPriority()
        {
            return priority;
        }

        public override bool testRequirements(WebBrowser browser)
        {
            if (browser.Document == null) return false;

            if (actions.Count > 0) return true;
            TimeSpan tsWait = SkillsDetector.getWaitTimeSpan(browser);
            DateTime dateToStart = DateTime.Now.AddSeconds(tsWait.TotalSeconds);
            if (dateToStart > DateTime.Now) 
            {
                status = "Активация планируется в " + dateToStart.ToShortTimeString();
                return false;
            }
            if (browser.Url.AbsolutePath != browser.Url.Scheme + "://" + strOKurl)
                actions.Add(new Action("", NavigateToOK));
            actions.Add(new Action("", CheckStatus));
            return true;
        }

        public override DialogResult showSetupDialog()
        {
            return setup.ShowDialog();
        }

        public override void initActions()
        {
            actions.Clear();
        }

        public void NavigateToOK(WebBrowser b) 
        {
            b.Navigate(strOKurl);
        }

        public void CheckStatus(WebBrowser b) 
        {
            
        }

    }
}
